//
//  BaseTabBarController.m
//  GK
//
//  Created by Seven on 2019/1/17.
//  Copyright © 2019 Seven. All rights reserved.
//

#import "BaseTabBarController.h"

@interface BaseTabBarController ()

@end

@implementation BaseTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

- (BOOL)shouldAutorotate{
    if (self.selectedViewController){
        return self.selectedViewController.shouldAutorotate;
    }
    return YES;
}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations{
    if (self.selectedViewController) {
        return self.selectedViewController.supportedInterfaceOrientations;
    }
    return UIInterfaceOrientationMaskPortrait;
}

BaseTabBarController * MainTabbarController(void){
    BaseTabBarController *tabbar = [UIApplication sharedApplication].delegate.window.rootViewController;
    if ([tabbar isKindOfClass:[BaseTabBarController class]]) {
        return tabbar;
    }
    return nil;
}

UINavigationController *SelectedNavController(void){
    BaseTabBarController *tabbar = MainTabbarController();
    if (tabbar) {
        return tabbar.selectedViewController;
    }else{
        return (UINavigationController *)[UIApplication sharedApplication].delegate.window.rootViewController;
    }
    return nil;
}

@end
